package xyz.xiangyushui.controller.membership.myMembership;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import xyz.xiangyushui.dao.user.member.MembershipDao;
import xyz.xiangyushui.javaBean.membership.Membership;

/**
 * Servlet implementation class MyMembership
 */
@WebServlet("/member/myMembership")
public class MyMembership extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private MembershipDao md;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public MyMembership() {
		super();
		md = new MembershipDao();
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Membership m=md.getMembershipInfo((String)request.getSession(false).getAttribute("userName"));
		request.setAttribute("rating", m.getRating());
		request.setAttribute("balance", m.getBalance());
		request.setAttribute("points", m.getPoints());
		request.setAttribute("cardId", m.getCardId());
		request.getRequestDispatcher("/member/myMembership/index.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
